Python/Python Functions MCQS Set 1 Sample Test,Sample questions

Question:
Which keyword is used to begin the definition of a function?

1.Define

2.DEF

3.def

4.Def

Posted Date:-2021-12-12 09:08:36


Question:
 A module is save with extension ____________

1..py

2..pym

3..mpy

4..mps

Posted Date:-2021-12-12 09:48:12


Question:
 def cal(n1) : What is n1?

1.Parameter

2.Argument

3.Keyword

4.None of the above

Posted Date:-2021-12-12 09:16:02


Question:
 Fill in the blank so that the output is 9:
a = 9
def sound():
   ________ a
   print(a)
sound()

1.local

2.global

3.outer

4.var

Posted Date:-2021-12-12 09:33:49


Question:
 How many built-in functions are used in the following code:
a = int(input("Enter a number: ")
b = a * a
print(" The square of ",a ,"is", b)

1.1

2.2

3.3

4.4

Posted Date:-2021-12-12 09:35:18


Question:
 How many built-in functions are used in the following code:
a = int(input("Enter a number: ")
b = a * a
print(" The square of ",a ,"is", b)

1.input( )

2.tuple( )

3.print( )

4.dictionary( )

Posted Date:-2021-12-12 09:36:20


Question:
 The return statement in function is used to _____

1.return value

2.returns the control to the calling function

3.Both of the above

4.None of the above

Posted Date:-2021-12-12 09:27:55


Question:
 What is the minimum and maximum value of ‘v’ in the following statement.
import random
v=random.randrange(20)-3
print(v)

1.0,19 b.

2.0,17

3.3,16

4.-3,17

Posted Date:-2021-12-12 10:32:41


Question:
 Which of the following function headers is correct?

1. def cal_si(p=100, r, t=2):

2.def cal_si(p=100, r=8, t):

3. def cal_si(p, r=8, t):

4.def cal_si(p, r=8, t=2):

Posted Date:-2021-12-12 10:03:40


Question:
 Which of the following options can be the output for the following code?
import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
       x = random.randint(1,3)
       print(List[x],end="#")

1. Delhi#Mumbai#Chennai#Kolkata#

2. Mumbai#Chennai#Kolkata#Mumbai#

3. Mumbai#Chennai#Kolkata#Mumbai#

4.Mumbai# Mumbai #Chennai # Mumbai

Posted Date:-2021-12-12 10:00:12


Question:
 Write the output of : print(max([1, 2, 3, 4], [4, 5, 6], [7]))

1.[1, 2, 3, 4]

2.[4, 5, 6]

3.[7]

4.7

Posted Date:-2021-12-12 09:42:25


Question:
 Write the output of the following :
print(math.floor(-4.5))

1.-4

2.-5

3.4

4.5

Posted Date:-2021-12-12 09:52:08


Question:
 Write the output of the following code :

import random
for i in range(random.randint(2, 2)):
         print(i)

1.0 1

2.1 2

3.0 1 2

4.Generate different number

Posted Date:-2021-12-12 10:26:57


Question:
A = random._______________([1,2,3,4,5]). Fill in the blank so that ‘A’ may have any value from the list.

1. shuffle

2.choice

3.uniform

4.None of the above

Posted Date:-2021-12-12 10:34:25


Question:
A function can be called __________ times in a program.

1.3

2.7

3.4

4.any number of

Posted Date:-2021-12-12 10:54:01


Question:
A function may return multiple values using _

1.List

2.Tuple

3.String

4.Dictionary

Posted Date:-2021-12-12 09:30:44


Question:
A Python standard library consists of a number of modules

1.A Python standard library consists of a number of modules

2.Library and modules are alias of each other.

3.A Module consists of a number of Python standard libraries

4.None of the above

Posted Date:-2021-12-12 09:46:32


Question:
A variable that is defined inside any function or a block is known as a ___

1.Global variable

2.Local variable

3.Function Variable

4. inside variable

Posted Date:-2021-12-12 09:33:09


Question:
Aman wants to import only sqrt( ) function of math module. Help him to write the correct code.

1.import math

2.from math import sqrt

3. import sqrt from math

4.import sqrt

Posted Date:-2021-12-12 09:58:15


Question:
Arrange the following from Simple(small) to Complex(big).
Instructions, Functions, Library, Module

1.Instructions, Functions, Library, Module

2.Functions, Instructions, Library, Module

3.Module, Functions, Instructions, Library

4.Instructions, Functions, Module, Library

Posted Date:-2021-12-12 09:47:25


Question:
Choose the correct answer:
def s(n1): 
      print(n1) 
n2=4 
s(n2) 

Statement A : n1 and n2 have same memory Address
Statement B : both n1 and n2 are referring to the same value, so they  have same identity

1.Statement A is True and Statement B is False

2. Statement A is False and Statement B is True

3.Both the statements are True

4.Both the statements are False

Posted Date:-2021-12-12 09:19:43


Question:
Choose the correct statement

1.We can create function with no argument and no return value.

2.We can create function with no argument and with return value(s)

3.We can create function with argument(s) and no return value.

4.All of the above

Posted Date:-2021-12-12 09:29:02


Question:
Choose the correct statement to import Math module:

1. Import math

2.import math

3. import Math

4.Import Math

Posted Date:-2021-12-12 09:49:20


Question:
Choose the incorrect statement.

1.print(pow(2, 3))

2. print(pow(2.3, 3.2))

3.print(pow(2, 3, 2))

4.None of the above

Posted Date:-2021-12-12 09:44:16


Question:
Consider the following code and choose the incorrect statement.:
def s(n1):
      print(id(n1))
n2=4
s(n2)
print(id(n2))

1.Function name is ‘s’

2.Function ‘s’ is taking one parameter.

3.Both print statement will print the same value.

4.Both print statement will print different value.

Posted Date:-2021-12-12 09:22:18


Question:
Division of large programs into smaller programs. These smaller programs are called ____

1.Functions

2.Operators

3.logical programs

4.specific programs

Posted Date:-2021-12-12 10:51:27


Question:
Function defined to achieve some task as per the programmer’s requirement is called a __

1.user defined function

2. library function

3. built in functions

4.All the above

Posted Date:-2021-12-12 09:10:59


Question:
Functions created by user is called _____________ function

1.Inbuilt

2.Library

3. User defined

4.logical

Posted Date:-2021-12-12 10:50:09


Question:
Functions which are already defined in python is called a ________

1. user defined function

2.library functions

3. built in functions

4.Both b and c

Posted Date:-2021-12-12 09:12:02


Question:
Functions which do not return any value is called ___

1.default function

2. zero function

3. void function

4.null function

Posted Date:-2021-12-12 09:26:22


Question:
In a program, a function can be called ____________ times.

1.2

2.3

3.5

4.Multiple times

Posted Date:-2021-12-12 09:07:26


Question:
In math.ceil(x), what is x here?

1.An Integer

2.A Floating point number

3. An integer or floating point number

4.None of the above

Posted Date:-2021-12-12 09:51:26


Question:
In order to get a list of modules available in Python, we can use the __________ statement:

1.help(“module”)

2. list(“module”)

3.available(“module”)

4.show(“module”)

Posted Date:-2021-12-12 09:57:28


Question:
Smallest number return by statement random.randrange(2,7) is _______

1.2

2.7

3.-2

4.0

Posted Date:-2021-12-12 09:55:51


Question:
The function can be called in the program by writing function name followed by ___

1.[ ]

2.{ }

3.( )

4.None of the above

Posted Date:-2021-12-12 09:15:19


Question:
The part of the program where a variable is accessible is known as the __________ of that variable

1. scope

2.module

3.part

4.None of the above

Posted Date:-2021-12-12 09:31:32


Question:
The process of dividing a computer program into separate independent blocks of code with specific functionalities is known as _________.

1.Programming

2.Modular Programming

3.Modular Programming

4.Step Programming

Posted Date:-2021-12-12 09:06:05


Question:
The ____________ statement returns the values from the function to the calling function.

1. send

2.give

3.return

4.take

Posted Date:-2021-12-12 09:27:02


Question:
Use of functions _______________ the size of programs.

1. increases

2.reduces

3. makes no change in

4.None of the above

Posted Date:-2021-12-12 10:53:11


Question:
What is the minimum and maximum value of ‘A’ in the following statement.
import random
A=random.randint(2,30)
print(A)

1.3 and 30

2. 2 and 30

3. 2 and 29

4.2 and 28

Posted Date:-2021-12-12 10:28:39


Question:
What is the output of the following code snippet?
def ChangeVal(M,N):
     for i in range(N):
          if M[i]%5 == 0:
               M[i]//=5
          if M[i]%3 == 0:
               M[i]//=3
L = [25,8,75,12]
ChangeVal(L,4)
for i in L:
     print(i,end="#")

1.5#8#15#4#

2.5#8#5#4#

3. 5#8#15#14#

4.. 5#18#15#4#

Posted Date:-2021-12-12 10:25:27


Question:
What will be the output of the following code?
def my_func(var1=100, var2=200):
      var1 += 10
      var2 = var2 - 10
      return var1+var2
print(my_func(50),my_func())

1.100 200

2.150 300

3.250 75

4.250 300

Posted Date:-2021-12-12 10:23:49


Question:
What will be the output of the following code?
value = 50
def display(N):
     global value
     value = 25
     if N%7==0:
           value = value + N
    else:
           value = value - N
print(value, end="#")
display(20)
print(value)

1.50#50

2.50#5

3. 50#30

4.5#50#

Posted Date:-2021-12-12 10:24:34


Question:
What will be the output of the following code?
x = 3
def myfunc():
      global x
      x+=2
     print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')

1.3 5 5

2.5 5 5

3. 5 3 5

4.3 3 5

Posted Date:-2021-12-12 10:01:06


Question:
What will be the output of the following Python code?
def add (num1, num2):
       sum = num1 + num2
sum = add(20,30)
print(sum)

1. 50

2.0

3.Null

4.None

Posted Date:-2021-12-12 10:23:09


Question:
What will be the possible outcome of the following code:
import random
X =[1,2,3,4]
m = random.randint(0,3)
for i in range(m):
       print (X[i],"--",end=" ")

1. 1 —

2.1 — 2 —

3.1 — 2 — 3 —

4.All the above

Posted Date:-2021-12-12 10:26:10


Question:
Which module is to be imported for using randint( ) function?

1.rand

2.random

3.randomrange

4.randomrange

Posted Date:-2021-12-12 09:39:59


Question:
Which of the following are advantages of using function in program?

1.It increases readability of program.

2.It increases reusability.

3.It makes debugging easier.

4.All the above

Posted Date:-2021-12-12 09:10:12


Question:
Which of the following components are part of a function header in Python?
i. function name
ii. return statement
iii. parameter list
iv. def keyword

1. only i

2. i and iii

3. iii and iv

4. i, iii and iv

Posted Date:-2021-12-12 10:02:24


Question:
Which of the following function definition header is wrong?

1.def sum(n1, n2, n = 3):

2. def scan(p1, p2 = 4, p3 = 5):

3.def div(p1=4, p2, p3):

4.def mul(p1, n1, m1):

Posted Date:-2021-12-12 09:25:30


Question:
Which of the following function is not defined in statistics module?

1.mean( )

2. mode( )

3.median( )

4.sqrt( )

Posted Date:-2021-12-12 09:56:29


Question:
Which of the following function return random real number (float) in the range 0.0 to 1.0?

1.random( )

2.randint( )

3.randrange( )

4.None of the above

Posted Date:-2021-12-12 09:55:00


Question:
Which of the following is not a type conversion functions?

1.int( )

2.str( )

3.input( )

4.float( )

Posted Date:-2021-12-12 10:55:01


Question:
Which of the following is not built-in module in python?

1.math

2.random

3.statistics

4.arithmetic

Posted Date:-2021-12-12 09:50:31


Question:
Which of the following is not the scope of variable?

1.Local

2.Global

3.Outside

4.None of the above

Posted Date:-2021-12-12 09:32:14


Question:
Which of the following is not the type of function argument?

1.Required argument

2. Keyword argument

3. initial argument

4.default argument

Posted Date:-2021-12-12 09:37:23


Question:
Which of the following is the correct way to call a function?

1.my_func( )

2.def my_func( )

3.return my_func

4.call my_func( )

Posted Date:-2021-12-12 10:22:17


Question:
Which of the following method is not included in random module?

1.Shuffle( )

2.randrange( )

3. randomrange( )

4. uniform( )

Posted Date:-2021-12-12 10:33:40


Question:
Which of the following number can never be generated by the following code:
random.randrange(0, 100)

1.0

2.100

3.99

4.1

Posted Date:-2021-12-12 09:40:44


Question:
Which of the following return floating point number?

1.print(pow(2, 3))

2.print(pow(2.3, 3.2))

3.print(pow(2, 3, 2))

4.All the above

Posted Date:-2021-12-12 09:45:16


Question:
Which of the following statement is a function call?

1.call sum( )

2.def sum( )

3.sum( )

4.function sum( )

Posted Date:-2021-12-12 09:09:31


Question:
Which of the following statement is not true regarding functions?

1.A function definition begins with “define”

2. A function may or may not have parameters.

3.A function may or may not return value.

4. Function header always ends with a colon (:).

Posted Date:-2021-12-12 09:12:53


Question:
Which of the following statement is outside the function “sum”?
def sum():
        a = int(input(“Enter number”))#Statement 1
        b = int(input(“Enter number”)) #Statement 2
s = a + b #Statement 3
print(s) #Statement 4

1.Statement 1

2. Statement 2

3.Statement 3

4.Both Statement 3 and Statement 4

Posted Date:-2021-12-12 09:13:53


Question:
Which of the following statement will execute in last?
def s(n1): #Statement 1
      print(n1) #Statement 2
n2=4 #Statement 3
s(n2) #Statement 4

1. Statement 1

2. Statement 2

3. Statement 3

4. Statement 4

Posted Date:-2021-12-12 09:18:16


Question:
Which of the following statement will return error?
print(int("a")) #Statement1
print(str(123)) #Statement2

1.Statement1

2.Statement2

3.Statement3

4.Statement4

Posted Date:-2021-12-12 10:57:30


Question:
Which of the following subject will never printed in following code?

import random
L=["English", "Hindi", "Math", "Science", "SST", "CS", "IP"]
for i in range(random.randint(1, 6)):
       print(L[i])

1. CS and IP both

2. English

3.IP

4.English and Hindi both

Posted Date:-2021-12-12 10:31:52


Question:
Write the output of : print(abs(-45))

1.45.0

2.-45

3.45

4.None of the above

Posted Date:-2021-12-12 09:41:36


Question:
Write the output of : print(math.fabs(-6.7))

1.-6

2.6.7

3. -6.7

4.7

Posted Date:-2021-12-12 09:53:17


Question:
Write the output of : print(min(tuple(“computer”)))

1.c

2.o

3.u

4.t

Posted Date:-2021-12-12 09:43:04


Question:
Write the output of the following code :

import random
for i in range(random.randint(2,3)):
         print("A")

1.A A

2.A A A

3.A A OR A A A

4.Error

Posted Date:-2021-12-12 10:27:50


Question:
Write the output of the following code :
import random
A=random.randrange(20)
print(A)

1.Any number between 0 to 19 (including both)

2.Any number between 0 to 20 (including both)

3.Any number between 1 to 20 (including both)

4.None of the above

Posted Date:-2021-12-12 10:29:25


Question:
Write the output of the following code :
import random
print(int(random.random( )))

1.Any random number less than 1 and greater than 0

2.Always generate 0

3.Always generate 1

4.Shows Error

Posted Date:-2021-12-12 10:30:16


Question:
Write the output of the following code :
import random
print(int(random.random()*5))

1.Always generate 0

2.Generate any number between 0 to 4 (including both)

3.Generate any number between 0 to 5 (including both)

4.None of the above

Posted Date:-2021-12-12 10:31:04


Question:
Write the output of the following. print(int( ))

1. Error

2. Any random number

3.0

4.1

Posted Date:-2021-12-12 10:56:11


Question:
Write the output of the following:
a = 9
def sound():
    b = 7
    print(a)
sound()
print(b)

1.7 7

2.9 9

3.7 9

4.Error

Posted Date:-2021-12-12 09:34:34


Question:
Write the output of the following:
def cal(m,n):
     if m==n:
          return m*3
     else:
          return m*2
s = cal(9, 8)
print(s)

1.16

2.18

3.27

4.24

Posted Date:-2021-12-12 09:23:04


Question:
Write the output of the following:
def cal(m,n):
     if m==n:
          return m*3
     else:
          return n*2
s = cal("Amit", "Anuj")
print(s)

1.AmitAmitAmit

2.AmitAmit

3.AnujAnujAnuj

4. AnujAnuj

Posted Date:-2021-12-12 09:23:49


Question:
Write the output of the following:
def check():
   i = 5
   while i > 1:
         if i //2==0:
              x = i + 2
              i = i-1
        else:
             i = i-2
             x = i
   print (x)
check()

1.3 3

2.5 3

3.3 1

4.3 2

Posted Date:-2021-12-12 09:39:06


Question:
Write the output of the following:
def fn(n1, n2=7):
     n1=n1+n2
     print(n1)
fn(3, 9)

1.3

2.9

3.12

4.10

Posted Date:-2021-12-12 09:24:17


Question:
Write the output of the following:
def fn(n1, n2=7):
    n1=n1%n2
    print(n1)
fn(3%2, 9%2)

1.1

2.0

3.2

4.3

Posted Date:-2021-12-12 09:24:43


Question:
Write the output of the following:
def s(n1):
      print(n1)
n2=4
s(n2)

1.2

2.3

3.4

4.Error

Posted Date:-2021-12-12 09:17:24


Question:
Write the output of the following:
print("A")
def prnt():
      print("B")
print("C")
prnt()

1.A B C

2.B C A

3.A B

4.A C B

Posted Date:-2021-12-12 09:38:16


Question:
Write the output of the following:
sound()
def sound():
    print("sound" * 2)

1.sound

2.soundsound

3.NameError : name ‘sound’ is not defined

4.SyntaxError: invalid syntax

Posted Date:-2021-12-12 09:30:04


Question:
_______ function of math module calculates the factorial.

1.fact( )

2. facto( )

3.factorial( )

4.factor( )

Posted Date:-2021-12-12 09:54:19


Question:
_____________ can be defined as a named group of instructions that accomplish a specific task when it is invoked/called.

1.Function

2.Datatype

3.Token

4.Operator

Posted Date:-2021-12-12 09:06:50


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!